package com.hx.demo.util;

import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import com.hx.demo.domain.User;
import org.springframework.context.annotation.Bean;

public class UserCacheUtil {


    public static TimedCache<String, User> timedCache = CacheUtil.newTimedCache(60 * 60 * 1000);


    /**
     *
     * @param sessionId   request 请求的SessionId
     * @return
     */
    public static User getUser(String sessionId) {
        return timedCache.get(sessionId);
    }


    /**
     *
     * @param sessionId   request 请求的SessionId
     * @param user  用户实体
     * @return
     */
    public static void addUser(String sessionId, User user) {
        timedCache.put(sessionId, user);
    }

}
